package com.wobangkj.common.repository;

import com.wobangkj.common.model.crud.Company;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public interface CompanyRepository extends JpaRepository<Company, Long> {

    @Query(value = "select id from User where unionid=?1")
    List getIdByUnionid(String unionid);

    @Query(nativeQuery = true, value="select * from  company  where company_name like CONCAT('%',:company_name,'%') ")
    List<Company> findByNameLike(String company_name);


    /**
     * jpa 原生sql
     *
     * @param name
     * @param pageable
     * @return
     */
    @Query(nativeQuery = true,
            value = "select * from user " +
                    "where name like CONCAT('%',:name,'%') ")
    Page<Company> findByName(String name, Pageable pageable);
}
